<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    =={{msg}}==={{count}}
    <hr />
    <!-- 重复调用会触发多次 可以自调用，或者通过事件 -->
    methods:
    ===={{add()}}
    ===={{add()}}
    ===={{add()}}
    ===={{add()}}
    ===={{add()}}
    <hr />
    computed:
    <!-- 重复调用只会触发一次，有缓存，必须值发生改变才会触发 -->
    {{total}}
    {{total}}
    {{total}}
    {{total}}
    {{total}}
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.min.js"></script>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        msg: 'hello  vue',
        count: 10
      },
      methods: {
        add () {
          console.log(11111);
        }
      },
      computed: {
        total () {
          /* 有缓存 */
          console.log(2222);
          return this.count
        }
      }
    })

    // console.log(vm, 2222);
  </script>
</body>

</html>